package com.zzptc.shop.servlet;

import com.zzptc.shop.vo.News;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "NewsContentServlet")
public class NewsContentServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session=request.getSession();
        List<News> list= (List) session.getAttribute("news");
        int id= Integer.parseInt(request.getParameter("newId"));

        for (News news:list){
            if (news.equals(id)){
                session.setAttribute("newContent",news);
                request.getRequestDispatcher("news-view.jsp").forward(request,response);
            }
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
